<!DOCTYPE html>
<html lang="en">
<head>
<title>新增按钮权限页面</title> 
#@common()
<style type="text/css">
body { padding: 10px; background: #fff; }
/* .layui-form-label { min-width: 200px; } */
</style>
</head>
<body>
	<form class="layui-form layui-fluid" action="option/save">
		<input type="hidden" name="id" value="#(option.id)" />
		<input type="hidden" name="parentId" value="#(option.parentId??parentId)" />
		<input type="hidden" name="type" value="#(option.type??type)" />
		<div class="layui-form-item">
			<div class="layui-inline">
				<div class="layui-form-label">列名称</div>
				<div class="layui-input-inline" style="width:120px">
					<input autocomplete="off" type="text" name="label" 
						required lay-verify="required" placeholder="" class="layui-input"
						value="#(option.label)">
				</div>
				
				<div class="layui-form-label">列字段</div>
				<div class="layui-input-inline" style="width:120px">
					<input autocomplete="off" type="text" name="param" 
						required lay-verify="required" placeholder="" class="layui-input"
						value="#(option.param)">
				</div>
				
				<div class="layui-form-label">列宽度</div>
				<div class="layui-input-inline" style="width:80px">
					<input autocomplete="off" type="text" name="width" 
						placeholder="" class="layui-input"
						value="#(option.width)"/>
				</div>
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-inline ">
				<div class="layui-form-label">方法名</div>
				<div class="layui-input-inline">
					<input autocomplete="off" type="text" name="url" 
						placeholder="" class="layui-input"
						value="#(option.url)"/>
				</div>
				<div class="layui-input-inline text-right" style="width: 300px;">
					 <input type="checkbox" name="key" title="列表主键" value="true" #if(option.key) checked #end>
      				 <input type="checkbox" name="hidden" title="隐藏列表" value="true" #if(option.hidden) checked #end>
				</div>
			</div>
		</div>
		
		<div class="layui-form-item layui-form-text">
    		<label class="layui-form-label">方法体</label>
    		<div class="layui-input-inline" style="width: 500px;">
     		 	<textarea name="formatter" placeholder="请输入内容" class="layui-textarea" style="height: 300px;">#if(colFunc??)#(colFunc)#else#(option.formatter)#end</textarea>
    		</div>
  		</div>
		
		<div class="layui-form-item">
			<div class="layui-col-md6 text-right" style="margin-right:70px;">
				<button class="layui-btn layui-bg-blue" lay-submit lay-filter="option">保存数据</button>
				<button type="button" class="layui-btn layui-btn-primary" onclick="closeLayer()">关闭返回</button>
			</div>
		</div>
	</form>

	<script>
		//layui的相关数据加载
		layui.use('form', function() {
			var form = layui.form;
			//监听提交
			form.on('submit(option)', function(data) {
				Http.post('admin/option/save', data.field, function(res){
					if(res.succeed){
						parent.layer.msg('保存成功',{shade:0.1})
						closeLayer();
					} else {
						parent.layer.msg('保存失败')
					}
				})
				return false;
			});
		});
		
		/** 关闭系统菜单录入页面 */
		function closeLayer(){
			parent.jqGrid.reload();
			closeParentLayer();
		}
		
	</script>
</body>
</html>